﻿using Admin.Database.Enums;
using Admin.Database.Model;
using Framework.SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Admin.Database.SeedData
{
	/// <summary>
	/// 系统角色菜单表种子数据
	/// </summary>
	public class SysRoleMenuSeedData : ISqlSugarEntitySeedData<SysRoleMenu>
	{
		/// <summary>
		/// 种子数据
		/// </summary>
		/// <returns></returns>
		public IEnumerable<SysRoleMenu> HasData()
		{
			var roleMenuList = new List<SysRoleMenu>();

			var roleList = new SysRoleSeedData().HasData().ToList();
			var menuList = new SysMenuSeedData().HasData().ToList();
			var defaultMenuList = new List<SysRoleMenu>();

			// 第一个角色拥有全部默认菜单
			roleMenuList.AddRange(defaultMenuList.Select(u => new SysRoleMenu { Id = u.MenuId + (roleList[0].Id % 1300000000000), RoleId = roleList[0].Id, MenuId = u.MenuId }));
			return roleMenuList;
		}
	}
}
